package com.demo.hibernate.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import com.demo.hibernate.domain.HUserInformation;
import com.demo.hibernate.repository.LoginRegisterRepository;
import com.demo.hibernate.service.HLoginRegisterService;

@Service
public class HLoginRegisterImpl implements HLoginRegisterService {

	@Autowired
	private LoginRegisterRepository loginRegisterRepository;

	// 缓存 指定key keyGenerator
	@Cacheable(value = "login", keyGenerator = "keyGenerator") // 缓存,这里没有
	// @CachePut(value = "login", keyGenerator = "keyGenerator")
	@Override
	public HUserInformation login(HUserInformation userInformation) {
		return loginRegisterRepository.queryLogin(userInformation.getUserCode(), userInformation.getUserPassword());
	}

	@Override
	public HUserInformation register(HUserInformation userInformation) {
		return loginRegisterRepository.save(userInformation);
	}

	@Override
	public List<HUserInformation> queryList(Long s, Long e) {
		return loginRegisterRepository.queryListByConditions(s, e);
	}

	@Override
	public Page<HUserInformation> queryListPage(String search, Pageable pageable) {
		return loginRegisterRepository.queryListByConditionsPage(search, pageable);
	}

}
